package com.study.vueblog.controller;


import com.study.vueblog.entity.User;
import com.study.vueblog.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author snail
 * @since 2021-04-20
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/index/{id}")
    public void index(@PathVariable("id") Integer id){
        User user = userService.getById(id);
        System.out.println(user);
    }

    @GetMapping("/all")
    public void getAll(){
        List<User> list = userService.getAll();
        for (User user :
                list) {
            System.out.println(user);
        }
    }

}
